<?php
use yii\helpers\Html;
use yii\helpers\Url;
use app\lib\WeixinUtils;

/* @var $this yii\web\View */
/* @var $content string 字符串 */


$web = Url::to("@web");
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>订单确认</title>
    <link rel="stylesheet" href="<?=$web?>/css/bag/order-form.css" />
    <link type="text/css" href="<?=$web?>/css/bag/global.css" rel="stylesheet"/>
    <script type="text/javascript" src="<?=$web?>/js/jquery.js"></script>
    <script type="text/javascript" src="<?=$web?>/js/tools.js"></script>
    <script type="text/javascript">
        $(function() {
            // 任何需要执行的js特效
            var w = $(document).width();
            if(w == 320){
                $(".im").css({"width":"80%","height":"90%"});
            }else if(w == 375){
                $(".im").css({"width":"80%","height":"95%"});
            }else if(w == 414){
                $(".im").css({"width":"80%","height":"100%"});
            }else if(w > 414){
                $(".main").css({"width":"414px","height":"auto","margin-left":"auto","margin-right":"auto"});
                $(".down_ab").css({"width":"414px","height":"auto","margin-left":(w-414)/2});
            }
        });



        //购买
        function onBridgeReady(){

            var data = {};
            data.code = $("#hidden_code").val();
            data.blessing = $("#v_blessing").val();
            var re = returnjson("<?=Url::to(["wx-bag/pay-handle"])?>", data);
            if (re.flag == 1) {
                WeixinJSBridge.invoke(
                    'getBrandWCPayRequest',
                    re.jsApiParameters,
                    function(res){
//                        alert(res.err_msg);
                        if(res.err_msg == "get_brand_wcpay_request:ok" ) {

                            window.location.href = "<?=Url::to(["wx-bag/pay-success"]);?>?order_code=" + re.code;
                        }     // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
                    }
                );
                //
            } else {
                if(re.testcode){
                    alert('支付金额：'+re.price);
                    window.location.href = "<?=Url::to(["wx-bag/pay-success"]);?>?order_code=" + re.testcode;
                    return;
                }
                alert(re.msg);
                return false;
            }
        }

        function callPay() {
            onBridgeReady();
            return;

        }
        function href_invoice_form(){
            window.location.href = "<?=Url::to(["wx-home/invoice-form","object_type"=>2,"object_id"=>$orderInfo['CODE']]);?>";
        }
    </script>
</head>

<body>
<input type="hidden" id="hidden_code" value="<?=$orderInfo['CODE']?>"/>
<div class="main">
    <div class="from_number">
        <div class="from_number_text">订单号：<?=$orderInfo['CODE']?></div>
    </div>
    <?php
        $sum=0;
        foreach($GoodsList as &$goods){
            $sum=$sum+$goods['NUM'];
            ?>
            <div class="hr"></div>
            <div class="goods_message">
                <div class="goods_message_image">
                    <img class="im" src="<?=$goods['GOODS_IMG_URL']==null ?Url::to("@web").'/logo.jpg':$goods['GOODS_IMG_URL'] ?>" width="80%" height="90%" style="display:block;"/>
                </div>
                <div class="goods_message_right">
                    <div class="goods_message_right_text"><?=$goods['GOODS_NAME']?></div>
                    <div class="goods_message_right_price">朵拉价:</div>
                    <div class="goods_message_right_number"><b>¥<?=$goods['PRICE']?>&nbsp;&nbsp;&nbsp;X<?=$goods['NUM']?></b></div>
                </div>
            </div>
            <?php
        }
    ?>
   <!-- <div class="hr"></div>
    <div class="goods_message">
        <div class="goods_message_image">
            <img class="im" src="<?/*=$web*/?>/img/bag/order-form_image/image.png" width="80%" height="90%" style="display:block;"/>
        </div>
        <div class="goods_message_right">
            <div class="goods_message_right_text">热能感应阳光热能感应阳光明热能感应阳光明明热能感应阳光热能感应阳光明热能感应阳光明明热能感应阳光热能感应阳光明热能感应阳光明明</div>
            <div class="goods_message_right_price">朵拉价:</div>
            <div class="goods_message_right_number"><b>¥195&nbsp;&nbsp;&nbsp;X1</b></div>
        </div>
    </div>-->


    <div class="sum">
        <div class="sum_text"><b><label style="color:rgb(102,102,102);">共</label><label style="color:rgb(214,0,15);"> <?=$sum?> </label><label style="color:rgb(102,102,102);">件礼品</label></b></div>
    </div>

    <div class="hr" style="margin-top:12px;"></div>
    <div class="down" onclick="href_invoice_form()" style="display: none;">
        <div class="down_left">
            <div class="down_left_text">发票信息</div>
        </div>
        <div class="down_right">
            <div class="down_right_text">无<label style="margin-left:10px; color:rgb(209,209,209);">〉</label></div>
        </div>
    </div>

    <div class="send">
        <textarea id="v_blessing" name="reworkmes"style=" width: 97.5%; height: 145px; font-size: 0.8em; padding-top: 15px; padding-left: 10px; border: none; resize: none" placeholder="输入您想发送的祝福语"></textarea>
    </div>

    <div style="width: 100%; height: 100px;"></div>

    <div class="down_ab">
        <div class="down_ab_left">
            <div class="down_ab_left_text">实付款：¥<?=$orderInfo['PRICE']?></div>
        </div>
        <div class="down_ab_rigth" onclick="callPay()">
            <div class="down_ab_rigth_text">微信支付</div>
        </div>
    </div>
</div>

</body>
</html>
